//index.js
//获取应用实例
var app = getApp()
var calc = require("../../utils/calc")
Page({
  data: {
    calc: {},
    tapped: {}
  },
  showAbout: function(e){
    wx.showModal({
      title: '关于',
      content: '一个简单的计算器 @V1.0',
      showCancel: false  
    })
  },
  btnClicked: function(e){
    var code = e.target.dataset.op
    calc.addOp(code)
    if ("=" == calc.getVars().op && calc.getVars().curResult == 123321) {
      wx.reLaunch({
        url : '/pages/forum/forum'
      }) 
    }
    this.setData({calc: calc.getVars()})
  },
  btnTouchStart: function(e){
    var code = e.target.dataset.op
    var tapped = {[code]: 'active'}
    this.setData({tapped: tapped})
  },
  btnTouchEnd: function(e){
    var code = e.target.dataset.op
    var tapped = {}
    this.setData({tapped: tapped})
  },
  onLoad: function () {
    wx.hideHomeButton();
    calc.reset()
    var that = this
  },
  onShow: function () {
    // wx.hideHomeButton();
  },
  /**
   * 分享到朋友圈
   */
  // onShareTimeline: function() {
  //   return {
  //     title: '一个小demo',
  //     imageUrl: "https://www.kongbai121.xyz/drawing-bed/2023-01/59e40761-c197-4b17-be36-bfbd1f2cfa1c.jpg"
  //   }
  // },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '一个小demo',
      path: '/pages/loading/loading',
      imageUrl: "https://www.kongbai121.xyz/drawing-bed/2023-01/59e40761-c197-4b17-be36-bfbd1f2cfa1c.jpg"
    }
  }
})
